package cn.wolfcode.crm.web.controller;

import cn.wolfcode.crm.domain.Menu;
import cn.wolfcode.crm.service.IMenuService;
import cn.wolfcode.crm.query.PageResult;
import cn.wolfcode.crm.query.QueryObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;


@Controller
@RequestMapping("menu")
public class MenuController {

    @Autowired
    private IMenuService menuService;

    //由于dataGrid组件返回必须为json,所以跳转界面就分开
    @RequestMapping("view")
    public String view() {
        return "menu";
    }

    //页面数据
    @RequestMapping("query")
    @ResponseBody
    public PageResult query(QueryObject qo) {
        return null;
    }

    //菜单树
    @RequestMapping("rootMenu")
    @ResponseBody
    public List<Menu> rootMenu(){
        return menuService.selectRooMenu();
    }
    //角色菜单回显
    @RequestMapping("roleMenu")
    @ResponseBody
    public List<Long> roleMenu(Long id){
        return menuService.selectMenuByRoleId(id);
    }

    //不同用户菜单的显示
    @RequestMapping("selectMenuByEmpId")
    @ResponseBody
    public List<Menu> selectMenuByEmpId(){
        return menuService.selectMenuByEmpId();
    }

}
